package cn.kgc.yigou.service;

import cn.kgc.yigou.mapper.ShopMapper;
import cn.kgc.yigou.pojo.Shop;
import cn.kgc.yigou.pojo.ShopExample;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("shopService")
public class ShopServiceImpl implements ShopService {
    @Resource
    ShopMapper shopMapper;

    @Override
    public void save(Shop shop) {
        shopMapper.insert(shop);
    }

    @Override
    public PageInfo<Shop> queryForKeywordWithPage(Integer pageNum, String keyword) {
        ShopExample example=new ShopExample();
        ShopExample.Criteria criteria=example.createCriteria();
        if (keyword!=null){
            criteria.andNameLike("%"+keyword+"%");
        }

        PageHelper.startPage(pageNum, 5);
        List<Shop> shops=shopMapper.selectByExample(example);
        PageInfo<Shop> pageInfo=new PageInfo<>(shops);
        return pageInfo;
    }

    @Override
    public List<Shop> getShopListByIdList(List<Integer> shopIdList) {
        return null;
    }

    @Override
    public Shop selectAllById(int id) {
        return null;
    }

    @Override
    public void batchRemove(List<Integer> shopIdList) {

    }

    @Override
    public void updateShop(Shop shop) {

    }
}
